﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetNeural.Metrics;

namespace DotNetNeural.Metric
{
    public class RectilinearMetric : IMetric
    {
        #region IMetric Members

        public float CalculateDistance(float[] lhs, float[] rhs)
        {
            if (lhs == null || rhs == null)
                throw new NullReferenceException("Illegal null-reference args");

            if (lhs.Length != rhs.Length)
                throw new ArgumentException("Both items should have the same dimensions");

            float sum = 0;

            for (int i = 0; i < lhs.Length; ++i)
            {
                sum += Math.Abs(lhs[i] - rhs[i]);
            }

            return sum;
        }

        #endregion
    }
}
